package com.stn.zjx.givingtreasure.activity.set;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.kyleduo.switchbutton.SwitchButton;
import com.stn.zjx.givingtreasure.R;
import com.stn.zjx.givingtreasure.base.BaseActivity;
import com.stn.zjx.givingtreasure.constants.StnConstants;
import com.stn.zjx.givingtreasure.event.NetWorkEvent;
import com.vondear.rxtools.RxActivityTool;
import com.vondear.rxtools.RxSPTool;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MsgSetActivity extends BaseActivity {
    @BindView(R.id.back_bt)
    RelativeLayout backBt;
    @BindView(R.id.action_title)
    TextView actionTitle;
    @BindView(R.id.action_add_bt)
    RelativeLayout actionAddBt;
    @BindView(R.id.msg_count_show)
    SwitchButton msgCountShow;

    @Override
    public void networkStatus(NetWorkEvent netWorkEvent) {

    }

    @Override
    public void initComponent() {
            actionTitle.setVisibility(View.VISIBLE);
             actionTitle.setText(getString(R.string.msg_set));
        SharedPreferences sp =getSharedPreferences(StnConstants.MSG_COUNT_SHOW, Context.MODE_PRIVATE);
        if(sp.getBoolean(StnConstants.MSG_COUNT_SHOW,true)){
            msgCountShow.setChecked(true);
        }else{
            msgCountShow.setChecked(false);
        }

        msgCountShow.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                 if (b){
                     RxSPTool.putBoolean(getApplicationContext(),StnConstants.MSG_COUNT_SHOW,true);
                 }else{
                     RxSPTool.putBoolean(getApplicationContext(),StnConstants.MSG_COUNT_SHOW,false);
                 }

            }
        });

    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_msg_set);
        ButterKnife.bind(this);
        initComponent();
    }

    @OnClick({R.id.back_bt})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back_bt:
                finish();
                break;
        }
    }
}
